﻿@using SmartCode
@using SmartCode.Db
@model BuildContext
@{
    Layout = "_CSharpLayout.cshtml";
    var project = Model.Project;
    var buildTask = Model.Build;
    var table = Model.GetCurrentTable();
}

@functions {
public string ConvertLangType(SmartCode.Generator.Entity.Column column)
{
    if (String.IsNullOrEmpty(column.LanguageType))
    {
        return "NAType";
    }
    if (!column.IsNullable)
    {
        return column.LanguageType;
    }

    if (column.LanguageType.Contains("[]") || column.LanguageType.ToLower() == "string")
    {
        return column.LanguageType;
    }
    return $"{column.LanguageType}?";
}

}

using System;
namespace @(project.Module).@buildTask.Module
{
@Html.PadLeft(4)@("///<summary>")
@Html.PadLeft(4)@($"///{table.Description ?? table.ConvertedName}")
@Html.PadLeft(4)@("///</summary>")
    public class @table.ConvertedName
    {
    @foreach (var column in table.Columns)
    {
        @Html.PadLeft(8)@("///<summary>")
        @Html.PadLeft(8)@Html.NewLine()
        @Html.PadLeft(8)@($"///{column.Description ?? column.ConvertedName}")
        @Html.PadLeft(8)@Html.NewLine()
        @Html.PadLeft(8)@("///</summary>")
        @Html.PadLeft(8)@Html.NewLine()
        @Html.PadLeft(8)<text>public</text> <text>@(ConvertLangType(column))</text> <text>@column.ConvertedName</text> <text>{ get; set; }</text>
        @Html.PadLeft(8)@Html.NewLine()
    }
    }
    }
